package com.wxapp.admin.service.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wxapp.admin.api.pojo.vm.company.PCompanyDetailVm;
import com.wxapp.admin.api.pojo.vm.company.PCompanyPageVm;
import com.wxapp.admin.api.pojo.vo.company.QCompanyAddPictureVo;
import com.wxapp.admin.api.pojo.vo.company.QCompanyPageVo;
import com.wxapp.admin.api.pojo.vo.company.QCompanySaveVo;
import com.wxapp.admin.api.pojo.vo.company.QCompanyUpdateVo;
import com.wxapp.admin.service.service.CompanyService;
import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.constant.pojo.vo.UserVo;
import com.wxapp.common.core.annotation.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lgl
 * @Description 公司
 * @Datetime 2022/6/2 10:36
 * @Modified By
 */
@RestController
@Tag(name = "公司管理")
@RequestMapping("company")
@RequiredArgsConstructor
public class CompanyController extends IBaseController {
    private final CompanyService companyService;

    @GetMapping("detail")
    @Operation(summary ="获取公司详细信息")
    public ResultVm<PCompanyDetailVm> detailCompany(@Schema(hidden = true) @User UserVo user, @RequestParam(value = "id", required = false) String id) {
        return companyService.detailCompany(user, id);
    }
    @PostMapping("page")
    @Operation(summary ="获取公司详细信息")
    public ResultVm<Page<PCompanyPageVm>> pageCompany(@RequestBody QCompanyPageVo qCompanyPageVo) {
        return companyService.pageCompany(qCompanyPageVo);
    }

    @PostMapping("/save")
    @Operation(summary ="保存公司信息")
    public ResultVm<String> saveCompany(@Schema(hidden = true) @User UserVo userVo, @RequestBody QCompanySaveVo qCompanySaveVo) {
        return companyService.saveCompany(userVo, qCompanySaveVo);
    }

    @PutMapping("/update")
    @Operation(summary ="更新公司信息")
    public ResultVm<String> updateCompany(@Schema(hidden = true) @User UserVo userVo, @RequestBody QCompanyUpdateVo qSaveVo) {
        return companyService.updateCompany(userVo, qSaveVo);
    }

    @DeleteMapping("/delete/{id}")
    @Operation(summary ="删除公司")
    public ResultVm<String> deleteCompany(@Schema(hidden = true) @User UserVo userVo, @PathVariable String id) {
        return companyService.deleteCompany(userVo, id);
    }

    @PostMapping("/addPicture")
    @Operation(summary ="添加公司图片")
    public ResultVm<String> addPicture(@Schema(hidden = true) @User UserVo userVo, @RequestBody QCompanyAddPictureVo qCompanyAddPictureVo) {
        return companyService.addPicture(userVo, qCompanyAddPictureVo);
    }

    @GetMapping("/getPicture")
    @Operation(summary ="获取公司图片")
    public ResultVm<List<String>> getPictureById(@RequestParam("companyId") String companyId) {
        return companyService.getPicture(companyId);
    }
  
}
